package com.itheima.exception;

import java.util.Scanner;

public class ExceptionDemo {
    public static void main(String[] args) {
        Student student=new Student();
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入年龄");
        while (true) {
            try {
                String age = scanner.nextLine();
                student.setAge(Integer.parseInt(age));
            } catch (NumberFormatException e) {
                e.printStackTrace();
                System.out.println("输入一个整数");
                continue;
        }
            catch (RuntimeException e){
                System.out.println("输入范围内的年龄");
                continue;
            }
        }
    }
}



